package com.yida.gwj.config.controller;

import java.util.List;
import javax.validation.Valid;

import com.yida.gwj.config.domain.GwjAttachmentConfig;
import com.yida.gwj.config.domain.request.GwjAttachmentConfigRequest;
import com.yida.gwj.config.service.IGwjAttachmentConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yida.common.log.annotation.Log;
import com.yida.common.log.enums.BusinessType;
import com.yida.common.core.web.controller.BaseController;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.core.web.page.TableDataInfo;

/**
 * 附件配置Controller
 *
 * @author ruoyi
 * @date 2023-04-19
 */
@Api(tags = "附件配置")
@RestController
@RequestMapping("/attachConfig")
public class GwjAttachmentConfigController extends BaseController {
    @Autowired
    private IGwjAttachmentConfigService gwjAttachmentConfigService;

    @ApiOperation("查询附件配置列表")
    //@RequiresPermissions("system:config:list")
    @GetMapping("/list")
    public TableDataInfo list(GwjAttachmentConfig gwjAttachmentConfig) {
        startPage();
        return getDataTable(gwjAttachmentConfigService.list(gwjAttachmentConfig));
    }

    @ApiOperation("获取附件配置详细信息")
    //@RequiresPermissions("system:config:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(gwjAttachmentConfigService.selectGwjAttachmentConfigById(id));
    }

    @ApiOperation("新增附件配置")
    //@RequiresPermissions("system:config:add")
    @Log(title = "附件配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody @Valid GwjAttachmentConfigRequest request) {
        return toAjax(gwjAttachmentConfigService.insertGwjAttachmentConfig(request));
    }

    @ApiOperation("修改附件配置")
    //@RequiresPermissions("system:config:edit")
    @Log(title = "附件配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody @Valid GwjAttachmentConfigRequest request) {
        return toAjax(gwjAttachmentConfigService.updateGwjAttachmentConfig(request));
    }

    @ApiOperation("删除附件配置")
    //@RequiresPermissions("system:config:remove")
    @Log(title = "附件配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(gwjAttachmentConfigService.deleteGwjAttachmentConfigByIds(ids));
    }


}
